package kr.saeildamil.androidstudy.ch17;

import java.io.File;

import kr.saeildamil.androidstudy.R;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.view.View;

public class CallOther extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.ch17_callother);
	}

	public void mOnClick(View v) {
		Intent intent;
		switch (v.getId()) {
		case R.id.ch17_callother_btn01:
			intent = new Intent(Intent.ACTION_VIEW,
					Uri.parse("http://www.naver.com"));
			startActivity(intent);
			break;
		case R.id.ch17_callother_btn02:
			intent = new Intent(Intent.ACTION_CALL,
					Uri.parse("tel:010-2060-6439"));
			startActivity(intent);
			break;
		case R.id.ch17_callother_btn03:
			String sdPath = Environment.getDownloadCacheDirectory()
					.getAbsolutePath();
			File file = new File(sdPath + "/sonnaeun.png");

			Uri uri = Uri.fromFile(file);

			intent = new Intent(Intent.ACTION_VIEW, uri);
			intent.setDataAndType(uri, "image/png");

			startActivity(intent);
			break;
		case R.id.ch17_callother_btn04:
			intent = new Intent(Intent.ACTION_MAIN);
			// intent.setClassName("com.example.otherapp",
			// "com.example.otherapp.MainActivity");
			ComponentName componetName = new ComponentName(
					"com.example.otherapp", "com.example.otherapp.MainActivity");
			intent.setComponent(componetName);

			startActivity(intent);
			break;
		}
	}
}
